package com.un.ebs.production.controller;


import com.baomidou.mybatisplus.core.metadata.IPage;
import com.un.ebs.core.util.WebResult;
import com.un.ebs.core.util.WebUtils;
import com.un.ebs.production.domain.ProductionWorkOrderExt;
import com.un.ebs.production.service.ProductionWorkOrderService;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import org.springframework.web.bind.annotation.*;

import javax.annotation.Resource;

/**
 * (ProductionWorkOrder)表控制层
 *
 * @author liubo
 * @since 2020-07-07 13:22:25
 */
@RestController
@RequestMapping("productionWorkOrder")
@Api(value = "production-work-order")
public class ProductionWorkOrderController {
    /**
     * 服务对象
     */
    @Resource
    private ProductionWorkOrderService service;

    @PostMapping("start")
    @ApiOperation(value = "开始")
    public WebResult start(@RequestParam String id) {
        service.start(id);
        return WebUtils.success();
    }

    @PostMapping("complete")
    @ApiOperation(value = "完工")
    public WebResult complete(@RequestParam String id) {
        service.complete(id);
        return WebUtils.success();
    }

    @PostMapping("completeFix")
    @ApiOperation(value = "完工，修复没有自动领料的")
    public WebResult completeFix() {
        service.completeFix();
        return WebUtils.success();
    }

    @PostMapping("completeOrder")
    @ApiOperation(value = "生产订单整单完工")
    public WebResult completeOrder(@RequestParam String productionOrderId) {
        service.completeOrder(productionOrderId);
        return WebUtils.success();
    }

    @PostMapping("completeOrderItem")
    @ApiOperation(value = "生产订单整单完工")
    public WebResult completeOrderItem(@RequestParam String productionOrderItemId) {
        service.completeOrderItem(productionOrderItemId);
        return WebUtils.success();
    }

    @GetMapping("list")
    @ApiOperation(value = "查询")
    public WebResult<IPage<ProductionWorkOrderExt>> query(@RequestParam(required = false) String searchText, @RequestParam String productionOrderItemId, @RequestParam int pageSize, @RequestParam int pageIndex) {
        return WebUtils.success(service.query(searchText, productionOrderItemId, pageSize, pageIndex));
    }

}